/*************************************************
 * LATEX EDITOR
 * By Red Team
 *
 *************************************************/
package com.meraklisina.latex ;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent ;
import java.awt.event.ActionListener ;
import java.awt.event.WindowAdapter ;
import java.awt.event.WindowEvent ;
import java.io.File ;
import java.io.FileNotFoundException ;
import java.io.IOException ;
import java.io.InputStream ;
import java.io.RandomAccessFile ;
import java.nio.ByteBuffer ;
import java.nio.channels.FileChannel ;
import java.util.ArrayList ;
import java.util.Vector ;
import java.util.logging.Level ;
import java.util.logging.Logger ;

import javax.swing.Icon ;
import javax.swing.JDialog ;
import javax.swing.JFrame ;
import javax.swing.JOptionPane ;
import javax.swing.JScrollPane ;
import javax.swing.JTextPane ;
import javax.swing.JViewport ;
import javax.swing.Timer ;
import javax.swing.event.DocumentEvent ;
import javax.swing.event.DocumentListener ;
import javax.swing.text.AttributeSet ;
import javax.swing.text.BadLocationException ;
import javax.swing.text.Element ;
import javax.swing.text.SimpleAttributeSet ;
import javax.swing.text.StyleConstants ;
import javax.swing.text.StyleContext ;
import javax.swing.text.StyledDocument ;
import javax.swing.undo.UndoManager ;

import org.jdesktop.application.Action ;
import org.jdesktop.application.FrameView ;
import org.jdesktop.application.ResourceMap ;
import org.jdesktop.application.SingleFrameApplication ;
import org.jdesktop.application.TaskMonitor ;

import com.sun.pdfview.PDFFile ;
import com.sun.pdfview.PDFPage ;
import com.sun.pdfview.PagePanel ;

/**
 * The application's main frame.
 */
public class LtxPrototypeView extends FrameView implements FileIOListener
{

    StateSave stSave = null ;

    public LtxPrototypeView( SingleFrameApplication app ) throws FileNotFoundException, Exception
    {
        super( app ) ;

        this.initComponents( ) ;
        this.readMenuXML( ) ;
        this.previewScrollPane.setVisible( this.previewBool ) ;

        this.fileIOHandler = new FileIOHandler( ) ;
        this.jButton33.setVisible( false ) ;
        //Preview();
        this.getFrame( ).addWindowListener( new MyWindowListener( ) ) ;

        //StateSave code here
        this.stSave = new StateSave( ) ;
        boolean saveFileExist = this.stSave.LoadPathsFromStateFile( ) ;

        if( !saveFileExist )
        {
            this.newTex( ) ;
        }
        else
        {
            ArrayList stateSavedFilePaths = new ArrayList( ) ;
            stateSavedFilePaths = this.stSave.ReturnPathlist( ) ;
            String filePath = "" ;
            String fullPath = "" ;
            String fileName = "" ;
            String fileContent = "" ;
            for( int i = 0; i < stateSavedFilePaths.size( ); i++ )
            {
                fullPath = String.valueOf( stateSavedFilePaths.get( i ) ) ;
                filePath = fullPath.substring( 0, fullPath.lastIndexOf( "\\" ) + 1 ) ;
                fileName = fullPath.substring( fullPath.lastIndexOf( "\\" ) + 1 ) ;
                try
                {
                    fileContent = this.fileIOHandler.getTextForAGivenPath( fullPath ) ;
                    this.addTab( fileName, filePath, fileContent ) ;
                    this.getLatexJTextPane( ).setPreviouslySaved( true ) ;
                }
                catch( Exception e )
                {
                }
            }
        }
        //StateSave code

        /*
         * The below 2 methods are to be used in the next version
         * as they are problematic at the moment and need to be worked on.
         *
         */
        //   addXmlButtons();
        //   addPdfViewer();
        this.fileIOHandler.subscribe( this ) ;
        this.fileIOHandler.loadConfigFile( ) ;

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = this.getResourceMap( ) ;
        int messageTimeout = resourceMap.getInteger( "StatusBar.messageTimeout" ) ;
        this.messageTimer = new Timer( messageTimeout, new ActionListener( )
        {

            public void actionPerformed( ActionEvent e )
            {
                LtxPrototypeView.this.statusMessageLabel.setText( "" ) ;
            }
        } ) ;
        this.messageTimer.setRepeats( false ) ;
        int busyAnimationRate = resourceMap.getInteger( "StatusBar.busyAnimationRate" ) ;
        for( int i = 0; i < this.busyIcons.length; i++ )
        {
            this.busyIcons[ i ] = resourceMap.getIcon( "StatusBar.busyIcons[" + i + "]" ) ;
        }
        this.busyIconTimer = new Timer( busyAnimationRate, new ActionListener( )
        {

            public void actionPerformed( ActionEvent e )
            {
                LtxPrototypeView.this.busyIconIndex = ( LtxPrototypeView.this.busyIconIndex + 1 ) % LtxPrototypeView.this.busyIcons.length ;
                LtxPrototypeView.this.statusAnimationLabel.setIcon( LtxPrototypeView.this.busyIcons[ LtxPrototypeView.this.busyIconIndex ] ) ;
            }
        } ) ;
        this.idleIcon = resourceMap.getIcon( "StatusBar.idleIcon" ) ;
        this.statusAnimationLabel.setIcon( this.idleIcon ) ;
        this.progressBar.setVisible( false ) ;

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor( this.getApplication( ).getContext( ) ) ;
        taskMonitor.addPropertyChangeListener( new java.beans.PropertyChangeListener( )
        {

            public void propertyChange( java.beans.PropertyChangeEvent evt )
            {
                String propertyName = evt.getPropertyName( ) ;
                if( "started".equals( propertyName ) )
                {
                    if( !LtxPrototypeView.this.busyIconTimer.isRunning( ) )
                    {
                        LtxPrototypeView.this.statusAnimationLabel.setIcon( LtxPrototypeView.this.busyIcons[ 0 ] ) ;
                        LtxPrototypeView.this.busyIconIndex = 0 ;
                        LtxPrototypeView.this.busyIconTimer.start( ) ;
                    }
                    LtxPrototypeView.this.progressBar.setVisible( true ) ;
                    LtxPrototypeView.this.progressBar.setIndeterminate( true ) ;
                }
                else if( "done".equals( propertyName ) )
                {
                    LtxPrototypeView.this.busyIconTimer.stop( ) ;
                    LtxPrototypeView.this.statusAnimationLabel.setIcon( LtxPrototypeView.this.idleIcon ) ;
                    LtxPrototypeView.this.progressBar.setVisible( false ) ;
                    LtxPrototypeView.this.progressBar.setValue( 0 ) ;
                }
                else if( "message".equals( propertyName ) )
                {
                    String text = ( String )( evt.getNewValue( ) ) ;
                    LtxPrototypeView.this.statusMessageLabel.setText( ( text == null ) ? "" : text ) ;
                    LtxPrototypeView.this.messageTimer.restart( ) ;
                }
                else if( "progress".equals( propertyName ) )
                {
                    int value = ( Integer )( evt.getNewValue( ) ) ;
                    LtxPrototypeView.this.progressBar.setVisible( true ) ;
                    LtxPrototypeView.this.progressBar.setIndeterminate( false ) ;
                    LtxPrototypeView.this.progressBar.setValue( value ) ;
                }
            }
        } ) ;

    }

    @Action
    public void preview( ) throws FileNotFoundException, IOException
    {
        String previewName = String.valueOf( ( int )( Math.random( ) * 10000 ) + "temp" ) ;
        String tempFileName, tempFilePath ;
        tempFileName = this.getLatexJTextPane( ).getFileName( ) ;
        tempFilePath = this.getLatexJTextPane( ).getFilePath( ) ;
        String tabName = this.jTabbedPane1.getTitleAt( this.jTabbedPane1.getSelectedIndex( ) ) ;
        //logTextArea.append(tempFileName+" "+tempFilePath);
        ( new File( "temp" ) ).mkdir( ) ;
        int a = this.fileIOHandler.compileForPreview( "temp/", previewName + ".tex", this.getLatexJTextPane( ).getText( ) ) ;
        //logTextArea.append(getLatexJTextPane().getText());
        this.getLatexJTextPane( ).setFileName( tempFileName ) ;
        this.getLatexJTextPane( ).setFilePath( tempFilePath ) ;

        if( tempFileName == "" )
        {
            this.changeTabName( tabName ) ;
        }
        else
        {
            this.getLatexJTextPane( ).setFileName( tempFileName ) ;
            this.getLatexJTextPane( ).setFilePath( tempFilePath ) ;
            this.changeTabName( tempFileName ) ;
        }
        PagePanel panel = new PagePanel( ) ;

        JFrame frame = new JFrame( "PDF Test" ) ;
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ) ;

        frame.add( panel ) ;
        frame.pack( ) ;
        frame.setVisible( false ) ;
        this.logTextArea.append( this.filePath ) ;
        //File file = new File("msg00736.pdf");
        File file = new File( "temp/" + previewName + ".pdf" ) ;
        RandomAccessFile raf = new RandomAccessFile( file, "r" ) ;
        FileChannel channel = raf.getChannel( ) ;
        ByteBuffer buf = channel.map( FileChannel.MapMode.READ_ONLY, 0, channel.size( ) ) ;
        PDFFile pdffile = new PDFFile( buf ) ;

        // show the first page
        PDFPage page = pdffile.getPage( 1 ) ;
        System.out.println( page.getPageNumber( ) ) ;
        // panel.showPage(page);
        panel.showPage( page ) ;
        //panel.setSize(previewScrollPane.getPreferredSize());
        this.previewPanel.add( panel ) ;
        //        panel.setAlignmentX(0);
        //        panel.setAlignmentY(0);
        panel.setBackground( new Color( 0, 0, 0 ) ) ;

        panel.setSize( ( int )panel.getPage( ).getWidth( ), ( int )panel.getPage( ).getHeight( ) ) ;
        this.previewPanel.setSize( panel.getSize( ) ) ;

        //pdffile.
        //panel.removeAll();
        // file.delete();
        //fileIOHandler.deleteTempPdf();
    }

    @Action
    public void showAboutBox( )
    {
        if( this.aboutBox == null )
        {
            JFrame mainFrame = LtxPrototypeApp.getApplication( ).getMainFrame( ) ;
            this.aboutBox = new LtxPrototypeAboutBox( mainFrame ) ;
            this.aboutBox.setLocationRelativeTo( mainFrame ) ;
        }
        LtxPrototypeApp.getApplication( ).show( this.aboutBox ) ;
    }

    /*
     * New tex Document
     * */
    @Action
    public void newTex( )
    {
        this.addTab( ) ;
        String initialString = "\\documentclass[english]{article}\n\\usepackage[T1]{fontenc}\n" + "\\usepackage[latin9]{inputenc}\n\\usepackage{babel}\n\\begin{document}\n\n\\end{document}" ;
        initialString = "\\documentclass[11pt]{article}"
                        + "\n\\usepackage{graphicx}    % needed for including graphics e.g. EPS, PS"
                        + "\n\\topmargin -1.5cm        % read Lamport p.163"
                        + "\n\\oddsidemargin -0.04cm   % read Lamport p.163"
                        + "\n\\evensidemargin -0.04cm  % same as oddsidemargin but for left-hand pages"
                        + "\n\\textwidth 16.59cm"
                        + "\n\\textheight 21.94cm"
                        + "\n%\\pagestyle{empty}       % Uncomment if don't want page numbers"
                        + "\n\\parskip 7.2pt           % sets spacing between paragraphs"
                        + "\n%\\renewcommand{\baselinestretch}{1.5} 	% Uncomment for 1.5 spacing between lines"
                        + "\n\\parindent 0pt		  % sets leading space for paragraphs"
                        + "\n\\begin{document}"
                        + "\n% Start your text\n"
                        + "\n% Stop your text"
                        + "\n\\end{document}" ;
        this.getActiveJTextPane( ).setText( "" ) ;
        Color c = new Color( 225, 225, 225 ) ;
        StyleContext sc = StyleContext.getDefaultStyleContext( ) ;
        AttributeSet aset = sc.addAttribute( SimpleAttributeSet.EMPTY, StyleConstants.Background, c ) ;
        this.getActiveJTextPane( ).setCharacterAttributes( aset, false ) ;
        this.getActiveJTextPane( ).replaceSelection( initialString ) ;
        this.getActiveJTextPane( ).setCaretPosition( initialString.length( ) - "\n% Stop your text\n\\end{document}".length( ) ) ;
        c = new Color( 255, 255, 255 ) ;
        aset = sc.addAttribute( aset, StyleConstants.Background, c ) ;
        this.getActiveJTextPane( ).setCharacterAttributes( aset, false ) ;
        this.fileIOHandler.setPreviouslySaved( false ) ;
        this.getActiveJTextPane( ).requestFocusInWindow( ) ;

    }

    /*
     * Save tex
     * */

    @Action
    public void tryRemove( )
    {
        this.removeTab( ) ;
    }

    @Action
    public void save( )
    {
        this.fileIOHandler.setPreviouslySaved( this.getLatexJTextPane( ).isPreviouslySaved( ) ) ;
        System.out.println( this.getLatexJTextPane( ).getFilePath( ) ) ;
        this.fileIOHandler.saveTex( this.getLatexJTextPane( ).getFilePath( ), this.getLatexJTextPane( ).getFileName( ), this.getLatexJTextPane( ).getText( ) ) ;
    }

    @Action
    public void confirmSave( )
    {
        int rtn = JOptionPane.YES_OPTION ; // default YES for confirm
        rtn = JOptionPane.showConfirmDialog( this.getActiveJTextPane( ), "Do you want to save?", "Confirm Save", JOptionPane.YES_NO_OPTION ) ;
        if( rtn == JOptionPane.YES_OPTION )
        {
            this.save( ) ;
        }
        else if( !this.replaceConfirm || ( rtn == JOptionPane.NO_OPTION ) )
        {
            return ;
        }
    }

    @Action
    public void saveAs( )
    {
        this.fileIOHandler.saveAsTex( this.getActiveJTextPane( ).getText( ) ) ;
    }

    /*
     * Open tex
     * */

    @Action
    public void load( )
    {

        String newText = this.fileIOHandler.openTex( ) ;
        if( newText != null )
        {
            //getActiveJTextPane().setText(newText);
            //String filePath =fileIOHandler.;
            this.addTab( this.fileIOHandler.getFileName( ), this.fileIOHandler.getFilePath( ), newText ) ;
        }
    }

    /*
     * Undo and redo use undomanager
     * */

    @Action
    public void undo( )
    {
        //System.out.print("undo action!!");
        LatexJTextPane tempPane = this.getLatexJTextPane( ) ;
        if( tempPane.undo.canUndo( ) )
        {

            tempPane.undo.undo( ) ;
        }
        else
        {
            System.out.println( "Can't Undo!" ) ;
        }
    }

    @Action
    public void redo( )
    {
        LatexJTextPane tempPane = this.getLatexJTextPane( ) ;
        if( tempPane.undo.canRedo( ) )
        {
            tempPane.undo.redo( ) ;
        }
        else
        {
            System.out.println( "Can't Redo!" ) ;
        }
    }

    /*
     * Reserved for next version
     * */

    @Action
    public void togglePdf( )
    {

        if( this.previewBool == true )
        {
            this.previewBool = false ;
            this.previewScrollPane.setVisible( this.previewBool ) ;
            this.previewScrollPane.setEnabled( this.previewBool ) ;
            this.mainPanel.revalidate( ) ;
            this.mainPanel.repaint( ) ;
        }
        else
        {
            this.previewBool = true ;
            this.previewScrollPane.setVisible( this.previewBool ) ;
            this.previewScrollPane.setEnabled( this.previewBool ) ;
            try
            {
                this.preview( ) ;
                this.mainPanel.revalidate( ) ;
                this.mainPanel.repaint( ) ;
            }
            catch( FileNotFoundException ex )
            {
                Logger.getLogger( LtxPrototypeView.class.getName( ) ).log( Level.SEVERE, null, ex ) ;
            }
            catch( IOException ex )
            {
                Logger.getLogger( LtxPrototypeView.class.getName( ) ).log( Level.SEVERE, null, ex ) ;
            }

        }
        System.out.println( "Preview is " + this.previewBool + "." ) ;
        //  addPdfViewer();
    }

    @Action
    public void Comment( JTextPane TextPane, boolean IsComment, String InsertedText )
    {
        try
        {
            Vector<Integer> LineNumbers = new Vector<Integer>( ) ;

            int SelectionStartOffset = TextPane.getSelectionStart( ) ;
            int SelectionEndOffset = TextPane.getSelectionEnd( ) ;
            int SelectionAdd = 0 ;

            int LineNumber = -1 ;
            StyledDocument stDoc = ( StyledDocument )TextPane.getDocument( ) ;

            if( ( SelectionStartOffset == SelectionEndOffset ) && ( TextPane.getCaretPosition( ) > -1 ) ) //Helps to comment out the line if user not selected anything
            {
                LineNumber = stDoc.getRootElements( )[ 0 ].getElementIndex( TextPane.getCaretPosition( ) ) ;

                LineNumbers.addElement( new Integer( LineNumber ) ) ;
            }
            else
            {
                for( int i = SelectionStartOffset; i < SelectionEndOffset; i++ )
                {
                    if( stDoc.getRootElements( )[ 0 ].getElementIndex( i ) != LineNumber )
                    {
                        LineNumber = stDoc.getRootElements( )[ 0 ].getElementIndex( i ) ;

                        LineNumbers.addElement( new Integer( LineNumber ) ) ;
                    }
                }
            }
            for( int Offset : LineNumbers )
            {
                Element map = stDoc.getDefaultRootElement( ) ;
                //int row = map.getElementIndex(position);
                Element lineElem = map.getElement( Offset ) ;
                //int col = Offset - lineElem.getStartOffset();
                int col = lineElem.getStartOffset( ) ;

                SimpleAttributeSet attributesIn = new SimpleAttributeSet( ) ;
                attributesIn = new SimpleAttributeSet( ) ;
                //                attributesIn.addAttribute(StyleConstants.CharacterConstants.Foreground, Color.LIGHT_GRAY);
                //                attributesIn.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE);

                SimpleAttributeSet attributesOut = new SimpleAttributeSet( ) ;
                attributesOut = new SimpleAttributeSet( ) ;
                //                attributesOut.addAttribute(StyleConstants.CharacterConstants.Foreground, Color.BLACK);
                //                attributesOut.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.FALSE);

                TextPane.select( lineElem.getStartOffset( ), lineElem.getEndOffset( ) ) ; //Selects the whole line
                String SelectedText = TextPane.getSelectedText( ) ; //Gets the selected string
                TextPane.replaceSelection( "" ) ; //Deletes the selected string from the pane

                if( IsComment )
                {
                    stDoc.insertString( col, InsertedText + SelectedText, attributesIn ) ;
                    SelectionAdd += InsertedText.length( ) ;
                }
                else
                {
                    stDoc.insertString( col, SelectedText.replaceFirst( InsertedText, "" ), attributesOut ) ;
                    SelectionAdd -= InsertedText.length( ) ;
                }
            }

            if( SelectionStartOffset != SelectionEndOffset )
            {
                TextPane.select( SelectionStartOffset, SelectionEndOffset + SelectionAdd ) ;
            }
        }
        catch( Exception ee )
        {
            ee.printStackTrace( ) ;
        }
    }

    /*
     *
     * This is where the latex commands are added.
     * If text is sellected it writes the prefix the selected text then the postfix.
     * Otherwise it writes the pre,postfixes then sets the carret to go in between them for convenience.
     * */
    @Action
    public void addLatexCommand( String prefix, String postfix )
    {
        String stringToChange = this.getActiveJTextPane( ).getSelectedText( ) ;
        int startPosition = this.getActiveJTextPane( ).getSelectionStart( ) ;
        int length = this.getActiveJTextPane( ).getSelectionEnd( ) - startPosition ;
        int caret = this.getActiveJTextPane( ).getCaretPosition( ) ;
        try
        {
            if( stringToChange == null )
            {
                this.getActiveJTextPane( ).getDocument( ).insertString( caret, prefix + postfix, null ) ;
                this.getActiveJTextPane( ).setCaretPosition( this.getActiveJTextPane( ).getCaretPosition( ) - postfix.length( ) ) ;
            }
            else
            {
                this.getActiveJTextPane( ).getDocument( ).remove( startPosition, length ) ;
                this.getActiveJTextPane( ).getDocument( ).insertString( startPosition, prefix + stringToChange + postfix, null ) ;
            }
        }
        catch( BadLocationException ex )
        {
            Logger.getLogger( LtxPrototypeView.class.getName( ) ).log( Level.SEVERE, null, ex ) ;
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     */
    @SuppressWarnings( "unchecked" )
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents( )
    {

        this.mainPanel = new javax.swing.JPanel( ) ;
        this.toolbarPanel = new javax.swing.JPanel( ) ;
        this.fileToolBar = new javax.swing.JToolBar( ) ;
        this.jButton1 = new javax.swing.JButton( ) ;
        this.jButton33 = new javax.swing.JButton( ) ;
        this.jButton2 = new javax.swing.JButton( ) ;
        this.jButton3 = new javax.swing.JButton( ) ;
        this.jButton4 = new javax.swing.JButton( ) ;
        this.jSeparator4 = new javax.swing.JToolBar.Separator( ) ;
        this.jButton5 = new javax.swing.JButton( ) ;
        this.jButton6 = new javax.swing.JButton( ) ;
        this.jButton11 = new javax.swing.JButton( ) ;
        this.jButton12 = new javax.swing.JButton( ) ;
        this.jButton13 = new javax.swing.JButton( ) ;
        this.jToggleButton1 = new javax.swing.JToggleButton( ) ;
        this.jToggleButton2 = new javax.swing.JToggleButton( ) ;
        this.jSeparator5 = new javax.swing.JToolBar.Separator( ) ;
        this.jButton7 = new javax.swing.JButton( ) ;
        this.jButton8 = new javax.swing.JButton( ) ;
        this.jButton9 = new javax.swing.JButton( ) ;
        this.jSeparator6 = new javax.swing.JToolBar.Separator( ) ;
        this.jButton22 = new javax.swing.JButton( ) ;
        this.jButton23 = new javax.swing.JButton( ) ;
        this.jButton10 = new javax.swing.JButton( ) ;
        this.jButton21 = new javax.swing.JButton( ) ;
        this.jSeparator13 = new javax.swing.JToolBar.Separator( ) ;
        this.jLabel6 = new javax.swing.JLabel( ) ;
        this.jButton14 = new javax.swing.JButton( ) ;
        this.jButton15 = new javax.swing.JButton( ) ;
        this.jButton16 = new javax.swing.JButton( ) ;
        this.jSeparator14 = new javax.swing.JToolBar.Separator( ) ;
        this.jLabel2 = new javax.swing.JLabel( ) ;
        this.jButton27 = new javax.swing.JButton( ) ;
        this.jScrollPane2 = new javax.swing.JScrollPane( ) ;
        this.logTextArea = new javax.swing.JTextArea( ) ;
        this.jLabel1 = new javax.swing.JLabel( ) ;
        this.findPanel = new javax.swing.JPanel( ) ;
        this.jLabel3 = new javax.swing.JLabel( ) ;
        this.findTextField = new javax.swing.JTextField( ) ;
        this.findPreviousButton = new javax.swing.JButton( ) ;
        this.jSeparator7 = new javax.swing.JSeparator( ) ;
        this.findNextButton = new javax.swing.JButton( ) ;
        this.caseSensitiveCheckBox = new javax.swing.JCheckBox( ) ;
        this.closeFindButton = new javax.swing.JButton( ) ;
        this.jSeparator9 = new javax.swing.JSeparator( ) ;
        this.jSeparator12 = new javax.swing.JSeparator( ) ;
        this.replacePanel = new javax.swing.JPanel( ) ;
        this.jLabel4 = new javax.swing.JLabel( ) ;
        this.replaceWhatField = new javax.swing.JTextField( ) ;
        this.jLabel5 = new javax.swing.JLabel( ) ;
        this.replaceWithField = new javax.swing.JTextField( ) ;
        this.replaceFindButton = new javax.swing.JButton( ) ;
        this.replaceReplaceButton = new javax.swing.JButton( ) ;
        this.jSeparator10 = new javax.swing.JSeparator( ) ;
        this.jSeparator11 = new javax.swing.JSeparator( ) ;
        this.replaceCaseSensitiveCheckBox = new javax.swing.JCheckBox( ) ;
        this.closeReplaceButton = new javax.swing.JButton( ) ;
        this.jSeparator8 = new javax.swing.JSeparator( ) ;
        this.jPanel1 = new javax.swing.JPanel( ) ;
        this.previewScrollPane = new javax.swing.JScrollPane( ) ;
        this.previewPanel = new javax.swing.JPanel( ) ;
        this.jScrollPane3 = new javax.swing.JScrollPane( ) ;
        this.jTabbedPane1 = new javax.swing.JTabbedPane( ) ;
        this.commandBar = new javax.swing.JToolBar( ) ;
        this.menuBar = new javax.swing.JMenuBar( ) ;
        javax.swing.JMenu fileMenu = new javax.swing.JMenu( ) ;
        this.jMenuItem1 = new javax.swing.JMenuItem( ) ;
        this.jMenuItem4 = new javax.swing.JMenuItem( ) ;
        this.jSeparator1 = new javax.swing.JSeparator( ) ;
        this.jMenuItem2 = new javax.swing.JMenuItem( ) ;
        this.jMenuItem3 = new javax.swing.JMenuItem( ) ;
        this.jSeparator3 = new javax.swing.JSeparator( ) ;
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem( ) ;
        this.editMenu = new javax.swing.JMenu( ) ;
        this.jMenuItem5 = new javax.swing.JMenuItem( ) ;
        this.jMenuItem6 = new javax.swing.JMenuItem( ) ;
        this.jSeparator2 = new javax.swing.JSeparator( ) ;
        this.jMenuItem14 = new javax.swing.JMenuItem( ) ;
        this.jMenuItem15 = new javax.swing.JMenuItem( ) ;
        this.jMenuItem16 = new javax.swing.JMenuItem( ) ;
        this.jMenuItem9 = new javax.swing.JMenuItem( ) ;
        this.jMenuItem12 = new javax.swing.JMenuItem( ) ;
        this.toolbarsMenu = new javax.swing.JMenu( ) ;
        this.compilationMenu = new javax.swing.JMenu( ) ;
        this.jMenuItem8 = new javax.swing.JMenuItem( ) ;
        this.jMenuItem10 = new javax.swing.JMenuItem( ) ;
        this.jMenuItem11 = new javax.swing.JMenuItem( ) ;
        this.jMenuItem13 = new javax.swing.JMenuItem( ) ;
        javax.swing.JMenu helpMenu = new javax.swing.JMenu( ) ;
        this.jMenuItem7 = new javax.swing.JMenuItem( ) ;
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem( ) ;
        this.statusPanel = new javax.swing.JPanel( ) ;
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator( ) ;
        this.statusMessageLabel = new javax.swing.JLabel( ) ;
        this.statusAnimationLabel = new javax.swing.JLabel( ) ;
        this.progressBar = new javax.swing.JProgressBar( ) ;

        this.mainPanel.setMaximumSize( new java.awt.Dimension( 1680, 1050 ) ) ;
        this.mainPanel.setMinimumSize( new java.awt.Dimension( 400, 200 ) ) ;
        this.mainPanel.setName( "mainPanel" ) ; // NOI18N
        this.mainPanel.setPreferredSize( new java.awt.Dimension( 850, 300 ) ) ;

        this.toolbarPanel.setMinimumSize( new java.awt.Dimension( 1032, 45 ) ) ;
        this.toolbarPanel.setName( "toolbarPanel" ) ; // NOI18N

        this.fileToolBar.setFloatable( false ) ;
        this.fileToolBar.setRollover( true ) ;
        this.fileToolBar.setMaximumSize( new java.awt.Dimension( 863, 32769 ) ) ;
        this.fileToolBar.setMinimumSize( new java.awt.Dimension( 833, 29 ) ) ;
        this.fileToolBar.setName( "fileToolBar" ) ; // NOI18N
        this.fileToolBar.setPreferredSize( new java.awt.Dimension( 863, 29 ) ) ;

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance( com.meraklisina.latex.LtxPrototypeApp.class ).getContext( ).getActionMap( LtxPrototypeView.class, this ) ;
        this.jButton1.setAction( actionMap.get( "newTex" ) ) ; // NOI18N
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance( com.meraklisina.latex.LtxPrototypeApp.class ).getContext( ).getResourceMap( LtxPrototypeView.class ) ;
        this.jButton1.setIcon( resourceMap.getIcon( "jButton1.icon" ) ) ; // NOI18N
        this.jButton1.setText( resourceMap.getString( "jButton1.text" ) ) ; // NOI18N
        this.jButton1.setToolTipText( resourceMap.getString( "jButton1.toolTipText" ) ) ; // NOI18N
        this.jButton1.setFocusable( false ) ;
        this.jButton1.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton1.setName( "jButton1" ) ; // NOI18N
        this.jButton1.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.jButton1.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jButton1ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jButton1 ) ;

        this.jButton33.setAction( actionMap.get( "tryRemove" ) ) ; // NOI18N
        this.jButton33.setIcon( resourceMap.getIcon( "jButton33.icon" ) ) ; // NOI18N
        this.jButton33.setText( resourceMap.getString( "jButton33.text" ) ) ; // NOI18N
        this.jButton33.setBorder( null ) ;
        this.jButton33.setMargin( new java.awt.Insets( 0, 0, 0, 0 ) ) ;
        this.jButton33.setMaximumSize( new java.awt.Dimension( 16, 16 ) ) ;
        this.jButton33.setMinimumSize( new java.awt.Dimension( 16, 16 ) ) ;
        this.jButton33.setName( "jButton33" ) ; // NOI18N
        this.jButton33.setPreferredSize( new java.awt.Dimension( 16, 16 ) ) ;
        this.fileToolBar.add( this.jButton33 ) ;

        this.jButton2.setAction( actionMap.get( "load" ) ) ; // NOI18N
        this.jButton2.setIcon( resourceMap.getIcon( "jButton2.icon" ) ) ; // NOI18N
        this.jButton2.setText( resourceMap.getString( "jButton2.text" ) ) ; // NOI18N
        this.jButton2.setToolTipText( resourceMap.getString( "jButton2.toolTipText" ) ) ; // NOI18N
        this.jButton2.setFocusable( false ) ;
        this.jButton2.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton2.setName( "jButton2" ) ; // NOI18N
        this.jButton2.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.fileToolBar.add( this.jButton2 ) ;

        this.jButton3.setAction( actionMap.get( "save" ) ) ; // NOI18N
        this.jButton3.setIcon( resourceMap.getIcon( "jButton3.icon" ) ) ; // NOI18N
        this.jButton3.setText( resourceMap.getString( "jButton3.text" ) ) ; // NOI18N
        this.jButton3.setToolTipText( resourceMap.getString( "jButton3.toolTipText" ) ) ; // NOI18N
        this.jButton3.setFocusable( false ) ;
        this.jButton3.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton3.setName( "jButton3" ) ; // NOI18N
        this.jButton3.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.fileToolBar.add( this.jButton3 ) ;

        this.jButton4.setAction( actionMap.get( "saveAs" ) ) ; // NOI18N
        this.jButton4.setIcon( resourceMap.getIcon( "jButton4.icon" ) ) ; // NOI18N
        this.jButton4.setText( resourceMap.getString( "jButton4.text" ) ) ; // NOI18N
        this.jButton4.setToolTipText( resourceMap.getString( "jButton4.toolTipText" ) ) ; // NOI18N
        this.jButton4.setFocusable( false ) ;
        this.jButton4.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton4.setName( "jButton4" ) ; // NOI18N
        this.jButton4.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.fileToolBar.add( this.jButton4 ) ;

        this.jSeparator4.setName( "jSeparator4" ) ; // NOI18N
        this.fileToolBar.add( this.jSeparator4 ) ;

        this.jButton5.setAction( actionMap.get( "undo" ) ) ; // NOI18N
        this.jButton5.setIcon( resourceMap.getIcon( "jButton5.icon" ) ) ; // NOI18N
        this.jButton5.setText( resourceMap.getString( "jButton5.text" ) ) ; // NOI18N
        this.jButton5.setToolTipText( resourceMap.getString( "jButton5.toolTipText" ) ) ; // NOI18N
        this.jButton5.setFocusable( false ) ;
        this.jButton5.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton5.setName( "jButton5" ) ; // NOI18N
        this.jButton5.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.fileToolBar.add( this.jButton5 ) ;

        this.jButton6.setAction( actionMap.get( "redo" ) ) ; // NOI18N
        this.jButton6.setIcon( resourceMap.getIcon( "jButton6.icon" ) ) ; // NOI18N
        this.jButton6.setText( resourceMap.getString( "jButton6.text" ) ) ; // NOI18N
        this.jButton6.setToolTipText( resourceMap.getString( "jButton6.toolTipText" ) ) ; // NOI18N
        this.jButton6.setFocusable( false ) ;
        this.jButton6.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton6.setName( "jButton6" ) ; // NOI18N
        this.jButton6.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.fileToolBar.add( this.jButton6 ) ;

        this.jButton11.setAction( actionMap.get( "cut" ) ) ;
        this.jButton11.setIcon( resourceMap.getIcon( "jButton11.icon" ) ) ; // NOI18N
        this.jButton11.setText( resourceMap.getString( "jButton11.text" ) ) ; // NOI18N
        this.jButton11.setToolTipText( resourceMap.getString( "jButton11.toolTipText" ) ) ; // NOI18N
        this.jButton11.setFocusable( false ) ;
        this.jButton11.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton11.setName( "jButton11" ) ; // NOI18N
        this.jButton11.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.fileToolBar.add( this.jButton11 ) ;

        this.jButton12.setAction( actionMap.get( "copy" ) ) ;
        this.jButton12.setIcon( resourceMap.getIcon( "jButton12.icon" ) ) ; // NOI18N
        this.jButton12.setText( resourceMap.getString( "jButton12.text" ) ) ; // NOI18N
        this.jButton12.setToolTipText( resourceMap.getString( "jButton12.toolTipText" ) ) ; // NOI18N
        this.jButton12.setFocusable( false ) ;
        this.jButton12.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton12.setName( "jButton12" ) ; // NOI18N
        this.jButton12.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.fileToolBar.add( this.jButton12 ) ;

        this.jButton13.setAction( actionMap.get( "paste" ) ) ;
        this.jButton13.setIcon( resourceMap.getIcon( "jButton13.icon" ) ) ; // NOI18N
        this.jButton13.setText( resourceMap.getString( "jButton13.text" ) ) ; // NOI18N
        this.jButton13.setToolTipText( resourceMap.getString( "jButton13.toolTipText" ) ) ; // NOI18N
        this.jButton13.setFocusable( false ) ;
        this.jButton13.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton13.setName( "jButton13" ) ; // NOI18N
        this.jButton13.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.fileToolBar.add( this.jButton13 ) ;

        this.jToggleButton1.setIcon( resourceMap.getIcon( "jToggleButton1.icon" ) ) ; // NOI18N
        this.jToggleButton1.setText( resourceMap.getString( "jToggleButton1.text" ) ) ; // NOI18N
        this.jToggleButton1.setFocusable( false ) ;
        this.jToggleButton1.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jToggleButton1.setName( "jToggleButton1" ) ; // NOI18N
        this.jToggleButton1.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.jToggleButton1.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jToggleButton1ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jToggleButton1 ) ;

        this.jToggleButton2.setIcon( resourceMap.getIcon( "jToggleButton2.icon" ) ) ; // NOI18N
        this.jToggleButton2.setText( resourceMap.getString( "jToggleButton2.text" ) ) ; // NOI18N
        this.jToggleButton2.setFocusable( false ) ;
        this.jToggleButton2.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jToggleButton2.setName( "jToggleButton2" ) ; // NOI18N
        this.jToggleButton2.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.jToggleButton2.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jToggleButton2ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jToggleButton2 ) ;

        this.jSeparator5.setName( "jSeparator5" ) ; // NOI18N
        this.fileToolBar.add( this.jSeparator5 ) ;

        this.jButton7.setIcon( resourceMap.getIcon( "jButton7.icon" ) ) ; // NOI18N
        this.jButton7.setText( resourceMap.getString( "jButton7.text" ) ) ; // NOI18N
        this.jButton7.setToolTipText( resourceMap.getString( "jButton7.toolTipText" ) ) ; // NOI18N
        this.jButton7.setFocusable( false ) ;
        this.jButton7.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton7.setName( "jButton7" ) ; // NOI18N
        this.jButton7.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.jButton7.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jButton7ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jButton7 ) ;

        this.jButton8.setIcon( resourceMap.getIcon( "jButton8.icon" ) ) ; // NOI18N
        this.jButton8.setText( resourceMap.getString( "jButton8.text" ) ) ; // NOI18N
        this.jButton8.setToolTipText( resourceMap.getString( "jButton8.toolTipText" ) ) ; // NOI18N
        this.jButton8.setFocusable( false ) ;
        this.jButton8.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton8.setName( "jButton8" ) ; // NOI18N
        this.jButton8.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.jButton8.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jButton8ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jButton8 ) ;

        this.jButton9.setIcon( resourceMap.getIcon( "jButton9.icon" ) ) ; // NOI18N
        this.jButton9.setText( resourceMap.getString( "jButton9.text" ) ) ; // NOI18N
        this.jButton9.setToolTipText( resourceMap.getString( "jButton9.toolTipText" ) ) ; // NOI18N
        this.jButton9.setFocusable( false ) ;
        this.jButton9.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton9.setName( "jButton9" ) ; // NOI18N
        this.jButton9.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.jButton9.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jButton9ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jButton9 ) ;

        this.jSeparator6.setName( "jSeparator6" ) ; // NOI18N
        this.fileToolBar.add( this.jSeparator6 ) ;

        this.jButton22.setIcon( resourceMap.getIcon( "jButton22.icon" ) ) ; // NOI18N
        this.jButton22.setText( resourceMap.getString( "jButton22.text" ) ) ; // NOI18N
        this.jButton22.setToolTipText( resourceMap.getString( "jButton22.toolTipText" ) ) ; // NOI18N
        this.jButton22.setFocusable( false ) ;
        this.jButton22.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton22.setName( "jButton22" ) ; // NOI18N
        this.jButton22.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.jButton22.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jButton22ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jButton22 ) ;

        this.jButton23.setIcon( resourceMap.getIcon( "jButton23.icon" ) ) ; // NOI18N
        this.jButton23.setText( resourceMap.getString( "jButton23.text" ) ) ; // NOI18N
        this.jButton23.setToolTipText( resourceMap.getString( "jButton23.toolTipText" ) ) ; // NOI18N
        this.jButton23.setFocusable( false ) ;
        this.jButton23.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton23.setName( "jButton23" ) ; // NOI18N
        this.jButton23.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.jButton23.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jButton23ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jButton23 ) ;

        this.jButton10.setIcon( resourceMap.getIcon( "jButton10.icon" ) ) ; // NOI18N
        this.jButton10.setText( resourceMap.getString( "jButton10.text" ) ) ; // NOI18N
        this.jButton10.setToolTipText( resourceMap.getString( "jButton10.toolTipText" ) ) ; // NOI18N
        this.jButton10.setFocusable( false ) ;
        this.jButton10.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton10.setName( "jButton10" ) ; // NOI18N
        this.jButton10.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.jButton10.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jButton10ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jButton10 ) ;

        this.jButton21.setIcon( resourceMap.getIcon( "jButton21.icon" ) ) ; // NOI18N
        this.jButton21.setToolTipText( resourceMap.getString( "jButton21.toolTipText" ) ) ; // NOI18N
        this.jButton21.setFocusable( false ) ;
        this.jButton21.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.jButton21.setName( "jButton21" ) ; // NOI18N
        this.jButton21.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
        this.jButton21.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jButton21ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jButton21 ) ;

        this.jSeparator13.setOrientation( javax.swing.SwingConstants.VERTICAL ) ;
        this.jSeparator13.setName( "jSeparator13" ) ; // NOI18N
        this.fileToolBar.add( this.jSeparator13 ) ;

        this.jLabel6.setText( resourceMap.getString( "jLabel6.text" ) ) ; // NOI18N
        this.jLabel6.setName( "jLabel6" ) ; // NOI18N
        this.fileToolBar.add( this.jLabel6 ) ;

        this.jButton14.setIcon( resourceMap.getIcon( "jButton14.icon" ) ) ; // NOI18N
        this.jButton14.setText( resourceMap.getString( "jButton14.text" ) ) ; // NOI18N
        this.jButton14.setName( "jButton14" ) ; // NOI18N
        this.jButton14.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jButton14ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jButton14 ) ;

        this.jButton15.setIcon( resourceMap.getIcon( "jButton15.icon" ) ) ; // NOI18N
        this.jButton15.setText( resourceMap.getString( "jButton15.text" ) ) ; // NOI18N
        this.jButton15.setActionCommand( resourceMap.getString( "jButton15.actionCommand" ) ) ; // NOI18N
        this.jButton15.setName( "jButton15" ) ; // NOI18N
        this.jButton15.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jButton15ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jButton15 ) ;

        this.jButton16.setIcon( resourceMap.getIcon( "jButton16.icon" ) ) ; // NOI18N
        this.jButton16.setText( resourceMap.getString( "jButton16.text" ) ) ; // NOI18N
        this.jButton16.setName( "jButton16" ) ; // NOI18N
        this.jButton16.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jButton16ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jButton16 ) ;

        this.jSeparator14.setOrientation( javax.swing.SwingConstants.VERTICAL ) ;
        this.jSeparator14.setName( "jSeparator14" ) ; // NOI18N
        this.fileToolBar.add( this.jSeparator14 ) ;

        this.jLabel2.setText( resourceMap.getString( "jLabel2.text" ) ) ; // NOI18N
        this.jLabel2.setAlignmentX( 4.0F ) ;
        this.jLabel2.setName( "jLabel2" ) ; // NOI18N
        this.fileToolBar.add( this.jLabel2 ) ;

        this.jButton27.setIcon( resourceMap.getIcon( "jButton27.icon" ) ) ; // NOI18N
        this.jButton27.setText( resourceMap.getString( "jButton27.text" ) ) ; // NOI18N
        this.jButton27.setToolTipText( resourceMap.getString( "jButton27.toolTipText" ) ) ; // NOI18N
        this.jButton27.setAlignmentX( 1.0F ) ;
        this.jButton27.setBorder( null ) ;
        this.jButton27.setMaximumSize( new java.awt.Dimension( 29, 27 ) ) ;
        this.jButton27.setName( "jButton27" ) ; // NOI18N
        this.jButton27.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jButton27ActionPerformed( evt ) ;
            }
        } ) ;
        this.fileToolBar.add( this.jButton27 ) ;

        javax.swing.GroupLayout toolbarPanelLayout = new javax.swing.GroupLayout( this.toolbarPanel ) ;
        this.toolbarPanel.setLayout( toolbarPanelLayout ) ;
        toolbarPanelLayout.setHorizontalGroup( toolbarPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup( toolbarPanelLayout.createSequentialGroup( ).addComponent( this.fileToolBar, javax.swing.GroupLayout.PREFERRED_SIZE, 928, javax.swing.GroupLayout.PREFERRED_SIZE ).addContainerGap( 138, Short.MAX_VALUE ) ) ) ;
        toolbarPanelLayout.setVerticalGroup( toolbarPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup( toolbarPanelLayout.createSequentialGroup( ).addComponent( this.fileToolBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE ).addContainerGap( ) ) ) ;

        this.jScrollPane2.setBorder( javax.swing.BorderFactory.createEtchedBorder( ) ) ;
        this.jScrollPane2.setMinimumSize( new java.awt.Dimension( 200, 100 ) ) ;
        this.jScrollPane2.setName( "jScrollPane2" ) ; // NOI18N
        this.jScrollPane2.setPreferredSize( new java.awt.Dimension( 200, 200 ) ) ;

        this.logTextArea.setColumns( 20 ) ;
        this.logTextArea.setEditable( false ) ;
        this.logTextArea.setRows( 5 ) ;
        this.logTextArea.setBorder( null ) ;
        this.logTextArea.setName( "logTextArea" ) ; // NOI18N
        this.jScrollPane2.setViewportView( this.logTextArea ) ;

        this.jLabel1.setText( resourceMap.getString( "jLabel1.text" ) ) ; // NOI18N
        this.jLabel1.setName( "jLabel1" ) ; // NOI18N

        this.findPanel.setBackground( resourceMap.getColor( "findPanel.background" ) ) ; // NOI18N
        this.findPanel.setEnabled( this.enabledFindPanel ) ;
        this.findPanel.setVisible( this.enabledFindPanel ) ;
        this.findPanel.setName( "findPanel" ) ; // NOI18N
        this.findPanel.setPreferredSize( new java.awt.Dimension( 800, 42 ) ) ;

        this.jLabel3.setText( resourceMap.getString( "jLabel3.text" ) ) ; // NOI18N
        this.jLabel3.setName( "jLabel3" ) ; // NOI18N

        this.findTextField.setText( resourceMap.getString( "findTextField.text" ) ) ; // NOI18N
        this.findTextField.setName( "findTextField" ) ; // NOI18N

        this.findPreviousButton.setText( resourceMap.getString( "findPreviousButton.text" ) ) ; // NOI18N
        this.findPreviousButton.setBorder( javax.swing.BorderFactory.createEtchedBorder( ) ) ;
        this.findPreviousButton.setName( "findPreviousButton" ) ; // NOI18N
        this.findPreviousButton.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.findPreviousButtonActionPerformed( evt ) ;
            }
        } ) ;

        this.jSeparator7.setOrientation( javax.swing.SwingConstants.VERTICAL ) ;
        this.jSeparator7.setName( "jSeparator7" ) ; // NOI18N

        this.findNextButton.setText( resourceMap.getString( "findNextButton.text" ) ) ; // NOI18N
        this.findNextButton.setBorder( javax.swing.BorderFactory.createEtchedBorder( ) ) ;
        this.findNextButton.setName( "findNextButton" ) ; // NOI18N
        this.findNextButton.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.findNextButtonActionPerformed( evt ) ;
            }
        } ) ;

        this.caseSensitiveCheckBox.setBackground( resourceMap.getColor( "caseSensitiveCheckBox.background" ) ) ; // NOI18N
        this.caseSensitiveCheckBox.setText( resourceMap.getString( "caseSensitiveCheckBox.text" ) ) ; // NOI18N
        this.caseSensitiveCheckBox.setName( "caseSensitiveCheckBox" ) ; // NOI18N
        this.caseSensitiveCheckBox.addItemListener( new java.awt.event.ItemListener( )
        {
            public void itemStateChanged( java.awt.event.ItemEvent evt )
            {
                LtxPrototypeView.this.caseSensitiveCheckBoxİtemStateChanged( evt ) ;
            }
        } ) ;

        this.closeFindButton.setIcon( resourceMap.getIcon( "closeFindButton.icon" ) ) ; // NOI18N
        this.closeFindButton.setText( resourceMap.getString( "closeFindButton.text" ) ) ; // NOI18N
        this.closeFindButton.setBorder( null ) ;
        this.closeFindButton.setBorderPainted( false ) ;
        this.closeFindButton.setMaximumSize( new java.awt.Dimension( 25, 19 ) ) ;
        this.closeFindButton.setMinimumSize( new java.awt.Dimension( 21, 19 ) ) ;
        this.closeFindButton.setName( "closeFindButton" ) ; // NOI18N
        this.closeFindButton.setPreferredSize( new java.awt.Dimension( 25, 19 ) ) ;
        this.closeFindButton.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.closeFindButtonActionPerformed( evt ) ;
            }
        } ) ;

        this.jSeparator9.setOrientation( javax.swing.SwingConstants.VERTICAL ) ;
        this.jSeparator9.setName( "jSeparator9" ) ; // NOI18N

        this.jSeparator12.setName( "jSeparator12" ) ; // NOI18N

        javax.swing.GroupLayout findPanelLayout = new javax.swing.GroupLayout( this.findPanel ) ;
        this.findPanel.setLayout( findPanelLayout ) ;
        findPanelLayout.setHorizontalGroup( findPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup( findPanelLayout.createSequentialGroup( ).addContainerGap( ).addGroup( findPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addComponent( this.jSeparator12, javax.swing.GroupLayout.DEFAULT_SIZE, 1179, Short.MAX_VALUE ).addGroup( findPanelLayout.createSequentialGroup( ).addComponent( this.jLabel3 ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.findTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED ).addComponent( this.jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.findPreviousButton, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.findNextButton, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.jSeparator9, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED ).addComponent( this.caseSensitiveCheckBox ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.closeFindButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) ) ).addContainerGap( ) ) ) ;
        findPanelLayout.setVerticalGroup( findPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup( findPanelLayout.createSequentialGroup( ).addContainerGap( ).addGroup( findPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup( findPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING, false ).addComponent( this.jSeparator7, javax.swing.GroupLayout.Alignment.LEADING ).addGroup( javax.swing.GroupLayout.Alignment.LEADING, findPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE ).addComponent( this.jLabel3 ).addComponent( this.findTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE ) ) ).addComponent( this.caseSensitiveCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE ).addComponent( this.findPreviousButton, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE ).addComponent( this.jSeparator9, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE ).addComponent( this.findNextButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE ).addComponent( this.closeFindButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.jSeparator12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) ) ) ;

        this.replacePanel.setBackground( resourceMap.getColor( "replacePanel.background" ) ) ; // NOI18N
        this.replacePanel.setEnabled( this.enabledReplacePanel ) ;
        this.replacePanel.setVisible( this.enabledReplacePanel ) ;
        this.replacePanel.setName( "replacePanel" ) ; // NOI18N
        this.replacePanel.setPreferredSize( new java.awt.Dimension( 800, 50 ) ) ;

        this.jLabel4.setText( resourceMap.getString( "jLabel4.text" ) ) ; // NOI18N
        this.jLabel4.setName( "jLabel4" ) ; // NOI18N

        this.replaceWhatField.setText( resourceMap.getString( "replaceWhatField.text" ) ) ; // NOI18N
        this.replaceWhatField.setName( "replaceWhatField" ) ; // NOI18N

        this.jLabel5.setText( resourceMap.getString( "jLabel5.text" ) ) ; // NOI18N
        this.jLabel5.setName( "jLabel5" ) ; // NOI18N

        this.replaceWithField.setText( resourceMap.getString( "replaceWithField.text" ) ) ; // NOI18N
        this.replaceWithField.setName( "replaceWithField" ) ; // NOI18N

        this.replaceFindButton.setText( resourceMap.getString( "replaceFindButton.text" ) ) ; // NOI18N
        this.replaceFindButton.setBorder( javax.swing.BorderFactory.createEtchedBorder( ) ) ;
        this.replaceFindButton.setName( "replaceFindButton" ) ; // NOI18N
        this.replaceFindButton.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.replaceFindButtonActionPerformed( evt ) ;
            }
        } ) ;

        this.replaceReplaceButton.setText( resourceMap.getString( "replaceReplaceButton.text" ) ) ; // NOI18N
        this.replaceReplaceButton.setBorder( javax.swing.BorderFactory.createEtchedBorder( ) ) ;
        this.replaceReplaceButton.setName( "replaceReplaceButton" ) ; // NOI18N
        this.replaceReplaceButton.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.replaceReplaceButtonActionPerformed( evt ) ;
            }
        } ) ;

        this.jSeparator10.setOrientation( javax.swing.SwingConstants.VERTICAL ) ;
        this.jSeparator10.setName( "jSeparator10" ) ; // NOI18N

        this.jSeparator11.setOrientation( javax.swing.SwingConstants.VERTICAL ) ;
        this.jSeparator11.setName( "jSeparator11" ) ; // NOI18N

        this.replaceCaseSensitiveCheckBox.setBackground( resourceMap.getColor( "replaceCaseSensitiveCheckBox.background" ) ) ; // NOI18N
        this.replaceCaseSensitiveCheckBox.setText( resourceMap.getString( "replaceCaseSensitiveCheckBox.text" ) ) ; // NOI18N
        this.replaceCaseSensitiveCheckBox.setName( "replaceCaseSensitiveCheckBox" ) ; // NOI18N
        this.replaceCaseSensitiveCheckBox.addItemListener( new java.awt.event.ItemListener( )
        {
            public void itemStateChanged( java.awt.event.ItemEvent evt )
            {
                LtxPrototypeView.this.replaceCaseSensitiveCheckBoxİtemStateChanged( evt ) ;
            }
        } ) ;

        this.closeReplaceButton.setIcon( resourceMap.getIcon( "closeReplaceButton.icon" ) ) ; // NOI18N
        this.closeReplaceButton.setText( resourceMap.getString( "closeReplaceButton.text" ) ) ; // NOI18N
        this.closeReplaceButton.setBorder( null ) ;
        this.closeReplaceButton.setBorderPainted( false ) ;
        this.closeReplaceButton.setName( "closeReplaceButton" ) ; // NOI18N
        this.closeReplaceButton.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.closeReplaceButtonActionPerformed( evt ) ;
            }
        } ) ;

        this.jSeparator8.setName( "jSeparator8" ) ; // NOI18N

        javax.swing.GroupLayout replacePanelLayout = new javax.swing.GroupLayout( this.replacePanel ) ;
        this.replacePanel.setLayout( replacePanelLayout ) ;
        replacePanelLayout.setHorizontalGroup( replacePanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup( replacePanelLayout.createSequentialGroup( ).addContainerGap( ).addGroup( replacePanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addComponent( this.jSeparator8, javax.swing.GroupLayout.DEFAULT_SIZE, 1179, Short.MAX_VALUE ).addGroup( replacePanelLayout.createSequentialGroup( ).addComponent( this.jLabel4 ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.replaceWhatField, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.jLabel5 ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.replaceWithField, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE ).addGap( 18, 18, 18 ).addComponent( this.jSeparator10, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.replaceFindButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.replaceReplaceButton, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED ).addComponent( this.jSeparator11, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.replaceCaseSensitiveCheckBox ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.closeReplaceButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE ) ) ).addContainerGap( ) ) ) ;
        replacePanelLayout.setVerticalGroup( replacePanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup( replacePanelLayout.createSequentialGroup( ).addContainerGap( ).addGroup( replacePanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addComponent( this.replaceFindButton, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE ).addComponent( this.replaceReplaceButton, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE ).addGroup( replacePanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE ).addComponent( this.replaceWhatField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ).addComponent( this.jLabel4 ).addComponent( this.jLabel5 ).addComponent( this.replaceWithField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) ).addComponent( this.jSeparator11, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE ).addComponent( this.replaceCaseSensitiveCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE ).addComponent( this.jSeparator10, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE ).addComponent( this.closeReplaceButton ) ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.jSeparator8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ).addGap( 11, 11, 11 ) ) ) ;

        this.jPanel1.setName( "jPanel1" ) ; // NOI18N

        this.previewScrollPane.setName( "previewScrollPane" ) ; // NOI18N
        this.previewScrollPane.setVisible( this.previewBool ) ;

        this.previewPanel.setAutoscrolls( true ) ;
        this.previewPanel.setName( "previewPanel" ) ; // NOI18N
        this.previewPanel.setPreferredSize( new java.awt.Dimension( 200, 600 ) ) ;

        javax.swing.GroupLayout previewPanelLayout = new javax.swing.GroupLayout( this.previewPanel ) ;
        this.previewPanel.setLayout( previewPanelLayout ) ;
        previewPanelLayout.setHorizontalGroup( previewPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGap( 0, 549, Short.MAX_VALUE ) ) ;
        previewPanelLayout.setVerticalGroup( previewPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGap( 0, 600, Short.MAX_VALUE ) ) ;

        this.previewScrollPane.setViewportView( this.previewPanel ) ;

        this.jScrollPane3.setName( "jScrollPane3" ) ; // NOI18N

        this.jTabbedPane1.setName( "jTabbedPane1" ) ; // NOI18N
        this.jScrollPane3.setViewportView( this.jTabbedPane1 ) ;

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout( this.jPanel1 ) ;
        this.jPanel1.setLayout( jPanel1Layout ) ;
        jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup( jPanel1Layout.createSequentialGroup( ).addComponent( this.jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.previewScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE ).addContainerGap( ) ) ) ;
        jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addComponent( this.jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE ).addComponent( this.previewScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE ) ) ;

        this.commandBar.setFloatable( false ) ;
        this.commandBar.setRollover( true ) ;
        this.commandBar.setName( "commandBar" ) ; // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout( this.mainPanel ) ;
        this.mainPanel.setLayout( mainPanelLayout ) ;
        mainPanelLayout.setHorizontalGroup( mainPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup( mainPanelLayout.createSequentialGroup( ).addContainerGap( ).addGroup( mainPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addComponent( this.commandBar, javax.swing.GroupLayout.PREFERRED_SIZE, 1168, javax.swing.GroupLayout.PREFERRED_SIZE ).addComponent( this.toolbarPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ).addComponent( this.jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE ).addComponent( this.jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 1199, Short.MAX_VALUE ).addComponent( this.jLabel1 ).addComponent( this.replacePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 1199, Short.MAX_VALUE ).addComponent( this.findPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 1199, Short.MAX_VALUE ) ).addContainerGap( ) ) ) ;
        mainPanelLayout.setVerticalGroup( mainPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup( mainPanelLayout.createSequentialGroup( ).addContainerGap( ).addComponent( this.toolbarPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.commandBar, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.findPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.replacePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.jLabel1 ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE ).addContainerGap( ) ) ) ;

        this.menuBar.setAlignmentX( 1.0F ) ;
        this.menuBar.setAlignmentY( 1.0F ) ;
        this.menuBar.setMinimumSize( new java.awt.Dimension( 219, 21 ) ) ;
        this.menuBar.setName( "menuBar" ) ; // NOI18N

        fileMenu.setText( resourceMap.getString( "fileMenu.text" ) ) ; // NOI18N
        fileMenu.setName( "fileMenu" ) ; // NOI18N

        this.jMenuItem1.setAction( actionMap.get( "newTex" ) ) ; // NOI18N
        this.jMenuItem1.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK ) ) ;
        this.jMenuItem1.setIcon( resourceMap.getIcon( "jMenuItem1.icon" ) ) ; // NOI18N
        this.jMenuItem1.setText( resourceMap.getString( "jMenuItem1.text" ) ) ; // NOI18N
        this.jMenuItem1.setName( "jMenuItem1" ) ; // NOI18N
        fileMenu.add( this.jMenuItem1 ) ;

        this.jMenuItem4.setAction( actionMap.get( "load" ) ) ; // NOI18N
        this.jMenuItem4.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK ) ) ;
        this.jMenuItem4.setIcon( resourceMap.getIcon( "jMenuItem4.icon" ) ) ; // NOI18N
        this.jMenuItem4.setText( resourceMap.getString( "jMenuItem4.text" ) ) ; // NOI18N
        this.jMenuItem4.setName( "jMenuItem4" ) ; // NOI18N
        fileMenu.add( this.jMenuItem4 ) ;

        this.jSeparator1.setName( "jSeparator1" ) ; // NOI18N
        fileMenu.add( this.jSeparator1 ) ;

        this.jMenuItem2.setAction( actionMap.get( "save" ) ) ; // NOI18N
        this.jMenuItem2.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK ) ) ;
        this.jMenuItem2.setIcon( resourceMap.getIcon( "jMenuItem2.icon" ) ) ; // NOI18N
        this.jMenuItem2.setText( resourceMap.getString( "jMenuItem2.text" ) ) ; // NOI18N
        this.jMenuItem2.setName( "jMenuItem2" ) ; // NOI18N
        fileMenu.add( this.jMenuItem2 ) ;

        this.jMenuItem3.setAction( actionMap.get( "saveAs" ) ) ; // NOI18N
        this.jMenuItem3.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK ) ) ;
        this.jMenuItem3.setIcon( resourceMap.getIcon( "jMenuItem3.icon" ) ) ; // NOI18N
        this.jMenuItem3.setText( resourceMap.getString( "jMenuItem3.text" ) ) ; // NOI18N
        this.jMenuItem3.setName( "jMenuItem3" ) ; // NOI18N
        fileMenu.add( this.jMenuItem3 ) ;

        this.jSeparator3.setName( "jSeparator3" ) ; // NOI18N
        fileMenu.add( this.jSeparator3 ) ;

        exitMenuItem.setAction( actionMap.get( "quit" ) ) ; // NOI18N
        exitMenuItem.setIcon( resourceMap.getIcon( "exitMenuItem.icon" ) ) ; // NOI18N
        exitMenuItem.setName( "exitMenuItem" ) ; // NOI18N
        fileMenu.add( exitMenuItem ) ;

        this.menuBar.add( fileMenu ) ;

        this.editMenu.setText( resourceMap.getString( "editMenu.text" ) ) ; // NOI18N
        this.editMenu.setName( "editMenu" ) ; // NOI18N

        this.jMenuItem5.setAction( actionMap.get( "undo" ) ) ; // NOI18N
        this.jMenuItem5.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_Z, java.awt.event.InputEvent.CTRL_MASK ) ) ;
        this.jMenuItem5.setIcon( resourceMap.getIcon( "jMenuItem5.icon" ) ) ; // NOI18N
        this.jMenuItem5.setText( resourceMap.getString( "jMenuItem5.text" ) ) ; // NOI18N
        this.jMenuItem5.setName( "jMenuItem5" ) ; // NOI18N
        this.editMenu.add( this.jMenuItem5 ) ;

        this.jMenuItem6.setAction( actionMap.get( "redo" ) ) ; // NOI18N
        this.jMenuItem6.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_Y, java.awt.event.InputEvent.CTRL_MASK ) ) ;
        this.jMenuItem6.setIcon( resourceMap.getIcon( "jMenuItem6.icon" ) ) ; // NOI18N
        this.jMenuItem6.setText( resourceMap.getString( "jMenuItem6.text" ) ) ; // NOI18N
        this.jMenuItem6.setName( "jMenuItem6" ) ; // NOI18N
        this.editMenu.add( this.jMenuItem6 ) ;

        this.jSeparator2.setName( "jSeparator2" ) ; // NOI18N
        this.editMenu.add( this.jSeparator2 ) ;

        this.jMenuItem14.setAction( actionMap.get( "cut" ) ) ;
        this.jMenuItem14.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK ) ) ;
        this.jMenuItem14.setIcon( resourceMap.getIcon( "jMenuItem14.icon" ) ) ; // NOI18N
        this.jMenuItem14.setText( resourceMap.getString( "jMenuItem14.text" ) ) ; // NOI18N
        this.jMenuItem14.setName( "jMenuItem14" ) ; // NOI18N
        this.editMenu.add( this.jMenuItem14 ) ;

        this.jMenuItem15.setAction( actionMap.get( "copy" ) ) ;
        this.jMenuItem15.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK ) ) ;
        this.jMenuItem15.setIcon( resourceMap.getIcon( "jMenuItem15.icon" ) ) ; // NOI18N
        this.jMenuItem15.setText( resourceMap.getString( "jMenuItem15.text" ) ) ; // NOI18N
        this.jMenuItem15.setName( "jMenuItem15" ) ; // NOI18N
        this.editMenu.add( this.jMenuItem15 ) ;

        this.jMenuItem16.setAction( actionMap.get( "paste" ) ) ;
        this.jMenuItem16.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK ) ) ;
        this.jMenuItem16.setIcon( resourceMap.getIcon( "jMenuItem16.icon" ) ) ; // NOI18N
        this.jMenuItem16.setText( resourceMap.getString( "jMenuItem16.text" ) ) ; // NOI18N
        this.jMenuItem16.setName( "jMenuItem16" ) ; // NOI18N
        this.editMenu.add( this.jMenuItem16 ) ;

        this.jMenuItem9.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.CTRL_MASK ) ) ;
        this.jMenuItem9.setIcon( resourceMap.getIcon( "jMenuItem9.icon" ) ) ; // NOI18N
        this.jMenuItem9.setText( resourceMap.getString( "jMenuItem9.text" ) ) ; // NOI18N
        this.jMenuItem9.setName( "jMenuItem9" ) ; // NOI18N
        this.jMenuItem9.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jMenuItem9ActionPerformed( evt ) ;
            }
        } ) ;
        this.editMenu.add( this.jMenuItem9 ) ;

        this.jMenuItem12.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK ) ) ;
        this.jMenuItem12.setIcon( resourceMap.getIcon( "jMenuItem12.icon" ) ) ; // NOI18N
        this.jMenuItem12.setText( resourceMap.getString( "jMenuItem12.text" ) ) ; // NOI18N
        this.jMenuItem12.setName( "jMenuItem12" ) ; // NOI18N
        this.jMenuItem12.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jMenuItem12ActionPerformed( evt ) ;
            }
        } ) ;
        this.editMenu.add( this.jMenuItem12 ) ;

        this.menuBar.add( this.editMenu ) ;

        this.toolbarsMenu.setText( resourceMap.getString( "toolbarsMenu.text" ) ) ; // NOI18N
        this.toolbarsMenu.setName( "toolbarsMenu" ) ; // NOI18N
        this.toolbarsMenu.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.toolbarsMenuActionPerformed( evt ) ;
            }
        } ) ;
        this.menuBar.add( this.toolbarsMenu ) ;

        this.compilationMenu.setText( resourceMap.getString( "compilationMenu.text" ) ) ; // NOI18N
        this.compilationMenu.setName( "compilationMenu" ) ; // NOI18N
        this.compilationMenu.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.compilationMenuActionPerformed( evt ) ;
            }
        } ) ;

        this.jMenuItem8.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_F5, 0 ) ) ;
        this.jMenuItem8.setIcon( resourceMap.getIcon( "jMenuItem8.icon" ) ) ; // NOI18N
        this.jMenuItem8.setText( resourceMap.getString( "jMenuItem8.text" ) ) ; // NOI18N
        this.jMenuItem8.setName( "jMenuItem8" ) ; // NOI18N
        this.jMenuItem8.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jMenuItem8ActionPerformed( evt ) ;
            }
        } ) ;
        this.compilationMenu.add( this.jMenuItem8 ) ;

        this.jMenuItem10.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_F6, 0 ) ) ;
        this.jMenuItem10.setIcon( resourceMap.getIcon( "jMenuItem10.icon" ) ) ; // NOI18N
        this.jMenuItem10.setText( resourceMap.getString( "jMenuItem10.text" ) ) ; // NOI18N
        this.jMenuItem10.setName( "jMenuItem10" ) ; // NOI18N
        this.jMenuItem10.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jMenuItem10ActionPerformed( evt ) ;
            }
        } ) ;
        this.compilationMenu.add( this.jMenuItem10 ) ;

        this.jMenuItem11.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_F7, 0 ) ) ;
        this.jMenuItem11.setIcon( resourceMap.getIcon( "jMenuItem11.icon" ) ) ; // NOI18N
        this.jMenuItem11.setText( resourceMap.getString( "jMenuItem11.text" ) ) ; // NOI18N
        this.jMenuItem11.setName( "jMenuItem11" ) ; // NOI18N
        this.jMenuItem11.addActionListener( new java.awt.event.ActionListener( )
        {
            public void actionPerformed( java.awt.event.ActionEvent evt )
            {
                LtxPrototypeView.this.jMenuItem11ActionPerformed( evt ) ;
            }
        } ) ;
        this.compilationMenu.add( this.jMenuItem11 ) ;

        this.jMenuItem13.setAction( actionMap.get( "togglePdf" ) ) ; // NOI18N
        this.jMenuItem13.setIcon( resourceMap.getIcon( "jMenuItem13.icon" ) ) ; // NOI18N
        this.jMenuItem13.setText( resourceMap.getString( "jMenuItem13.text" ) ) ; // NOI18N
        this.jMenuItem13.setName( "jMenuItem13" ) ; // NOI18N
        this.compilationMenu.add( this.jMenuItem13 ) ;

        this.menuBar.add( this.compilationMenu ) ;

        helpMenu.setText( resourceMap.getString( "helpMenu.text" ) ) ; // NOI18N
        helpMenu.setName( "helpMenu" ) ; // NOI18N

        this.jMenuItem7.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_F1, 0 ) ) ;
        this.jMenuItem7.setIcon( resourceMap.getIcon( "jMenuItem7.icon" ) ) ; // NOI18N
        this.jMenuItem7.setText( resourceMap.getString( "jMenuItem7.text" ) ) ; // NOI18N
        this.jMenuItem7.setToolTipText( resourceMap.getString( "jMenuItem7.toolTipText" ) ) ; // NOI18N
        this.jMenuItem7.setName( "jMenuItem7" ) ; // NOI18N
        helpMenu.add( this.jMenuItem7 ) ;

        aboutMenuItem.setAction( actionMap.get( "showAboutBox" ) ) ; // NOI18N
        aboutMenuItem.setIcon( resourceMap.getIcon( "aboutMenuItem.icon" ) ) ; // NOI18N
        aboutMenuItem.setName( "aboutMenuItem" ) ; // NOI18N
        helpMenu.add( aboutMenuItem ) ;

        this.menuBar.add( helpMenu ) ;

        this.statusPanel.setName( "statusPanel" ) ; // NOI18N
        this.statusPanel.setPreferredSize( new java.awt.Dimension( 800, 30 ) ) ;

        statusPanelSeparator.setName( "statusPanelSeparator" ) ; // NOI18N

        this.statusMessageLabel.setName( "statusMessageLabel" ) ; // NOI18N

        this.statusAnimationLabel.setHorizontalAlignment( javax.swing.SwingConstants.LEFT ) ;
        this.statusAnimationLabel.setName( "statusAnimationLabel" ) ; // NOI18N

        this.progressBar.setName( "progressBar" ) ; // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout( this.statusPanel ) ;
        this.statusPanel.setLayout( statusPanelLayout ) ;
        statusPanelLayout.setHorizontalGroup( statusPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup( statusPanelLayout.createSequentialGroup( ).addContainerGap( ).addGroup( statusPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup( statusPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addComponent( statusPanelSeparator, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1209, Short.MAX_VALUE ).addGroup( statusPanelLayout.createSequentialGroup( ).addComponent( this.statusMessageLabel ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, 1199, Short.MAX_VALUE ).addComponent( this.statusAnimationLabel ).addContainerGap( ) ) ).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup( ).addComponent( this.progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ).addGap( 163, 163, 163 ) ) ) ) ) ;
        statusPanelLayout.setVerticalGroup( statusPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup( statusPanelLayout.createSequentialGroup( ).addComponent( statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( this.progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ).addGap( 16, 16, 16 ).addComponent( this.statusAnimationLabel ).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE ).addComponent( this.statusMessageLabel ).addGap( 16, 16, 16 ) ) ) ;

        this.setComponent( this.mainPanel ) ;
        this.setMenuBar( this.menuBar ) ;
        this.setStatusBar( this.statusPanel ) ;
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jButton1ActionPerformed
        // getActiveJTextPane().setText(getActiveJTextPane().getText()+"Sasdasa");
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jMenuItem8ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jMenuItem8ActionPerformed
        this.save( ) ;
        this.fileIOHandler.tex2DviConverter( ) ;
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenuItem10ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jMenuItem10ActionPerformed
        this.save( ) ;
        this.fileIOHandler.tex2pdfConverter( ) ;
        this.filePath = this.fileIOHandler.getFilePath( ) ;
        this.pdfName = this.fileIOHandler.getPdfName( ) ;
        this.previewBool = false ;
        this.togglePdf( ) ;

    }//GEN-LAST:event_jMenuItem10ActionPerformed

    private void jButton7ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jButton7ActionPerformed
        this.addLatexCommand( "\\textbf{", "}" ) ;
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jButton8ActionPerformed
        this.addLatexCommand( "\\emph{", "}" ) ;
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton9ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jButton9ActionPerformed
        this.addLatexCommand( "\\underline{", "}" ) ;
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton22ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jButton22ActionPerformed
        this.addLatexCommand( "\\begin{center}", "\\end{center}" ) ;
    }//GEN-LAST:event_jButton22ActionPerformed

    private void jButton23ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jButton23ActionPerformed
        this.addLatexCommand( "\\begin{flushright}", "\\end{flushright}" ) ;
    }//GEN-LAST:event_jButton23ActionPerformed

    private void jButton10ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jButton10ActionPerformed
        //addLatexCommand("\\comments{", "}");
        this.Comment( this.getActiveJTextPane( ), true, "%" ) ;
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jMenuItem11ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jMenuItem11ActionPerformed
        this.save( ) ;
        this.fileIOHandler.dvi2psConverter( ) ;
    }//GEN-LAST:event_jMenuItem11ActionPerformed

    private void jButton27ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jButton27ActionPerformed
        this.fileIOHandler.extPDF( ) ; //open the PDF file externally.
    }//GEN-LAST:event_jButton27ActionPerformed

    private void toolbarsMenuActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_toolbarsMenuActionPerformed
    }//GEN-LAST:event_toolbarsMenuActionPerformed

    private void jButton21ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jButton21ActionPerformed
        this.Comment( this.getActiveJTextPane( ), false, "%" ) ;
    }//GEN-LAST:event_jButton21ActionPerformed

    private void findNextButtonActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_findNextButtonActionPerformed
        this.findNext( this.findTextField.getText( ) ) ;
    }//GEN-LAST:event_findNextButtonActionPerformed

    private void findPreviousButtonActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_findPreviousButtonActionPerformed
        this.findPrevious( this.findTextField.getText( ) ) ;
    }//GEN-LAST:event_findPreviousButtonActionPerformed

    private void jMenuItem9ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jMenuItem9ActionPerformed
        if( this.enabledReplacePanel )
        {
            this.enabledReplacePanel = !this.enabledReplacePanel ;
            this.replacePanel.setEnabled( this.enabledReplacePanel ) ;
            this.replacePanel.setVisible( this.enabledReplacePanel ) ;
        }
        this.enabledFindPanel = !this.enabledFindPanel ;
        this.findPanel.setEnabled( this.enabledFindPanel ) ;
        this.findPanel.setVisible( this.enabledFindPanel ) ;
        if( this.enabledFindPanel )
        {
            this.findTextField.requestFocusInWindow( ) ;
        }
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void closeFindButtonActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_closeFindButtonActionPerformed
        this.enabledFindPanel = false ;
        this.findPanel.setEnabled( this.enabledFindPanel ) ;
        this.findPanel.setVisible( this.enabledFindPanel ) ;
        this.jToggleButton1.setSelected( this.enabledFindPanel ) ;
    }//GEN-LAST:event_closeFindButtonActionPerformed

    private void closeReplaceButtonActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_closeReplaceButtonActionPerformed
        this.enabledReplacePanel = false ;
        this.replacePanel.setEnabled( this.enabledReplacePanel ) ;
        this.replacePanel.setVisible( this.enabledReplacePanel ) ;
        this.jToggleButton2.setSelected( this.enabledReplacePanel ) ;
    }//GEN-LAST:event_closeReplaceButtonActionPerformed

    private void replaceFindButtonActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_replaceFindButtonActionPerformed
        this.findNext( this.replaceWhatField.getText( ) ) ;
    }//GEN-LAST:event_replaceFindButtonActionPerformed

    private void caseSensitiveCheckBoxİtemStateChanged( java.awt.event.ItemEvent evt )
    {//GEN-FIRST:event_caseSensitiveCheckBoxİtemStateChanged
        this.findCase = this.caseSensitiveCheckBox.isSelected( ) ;
    }//GEN-LAST:event_caseSensitiveCheckBoxİtemStateChanged

    private void replaceCaseSensitiveCheckBoxİtemStateChanged( java.awt.event.ItemEvent evt )
    {//GEN-FIRST:event_replaceCaseSensitiveCheckBoxİtemStateChanged
        this.findCase = this.replaceCaseSensitiveCheckBox.isSelected( ) ;
    }//GEN-LAST:event_replaceCaseSensitiveCheckBoxİtemStateChanged

    private void replaceReplaceButtonActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_replaceReplaceButtonActionPerformed
        this.doReplaceWords( this.replaceWhatField.getText( ), this.replaceWithField.getText( ) ) ;
    }//GEN-LAST:event_replaceReplaceButtonActionPerformed

    private void jMenuItem12ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jMenuItem12ActionPerformed
        if( this.enabledFindPanel )
        {
            this.enabledFindPanel = !this.enabledFindPanel ;
            this.findPanel.setEnabled( this.enabledFindPanel ) ;
            this.findPanel.setVisible( this.enabledFindPanel ) ;
        }
        this.enabledReplacePanel = !this.enabledReplacePanel ;
        this.replacePanel.setEnabled( this.enabledReplacePanel ) ;
        this.replacePanel.setVisible( this.enabledReplacePanel ) ;
        if( this.enabledReplacePanel )
        {
            this.replaceWhatField.requestFocusInWindow( ) ;
        }
    }//GEN-LAST:event_jMenuItem12ActionPerformed

    private void jToggleButton1ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jToggleButton1ActionPerformed
        if( this.enabledReplacePanel )
        {
            this.enabledReplacePanel = !this.enabledReplacePanel ;
            this.replacePanel.setEnabled( this.enabledReplacePanel ) ;
            this.replacePanel.setVisible( this.enabledReplacePanel ) ;
            this.jToggleButton2.setSelected( this.enabledReplacePanel ) ;
        }
        this.enabledFindPanel = !this.enabledFindPanel ;
        this.findPanel.setEnabled( this.enabledFindPanel ) ;
        this.findPanel.setVisible( this.enabledFindPanel ) ;
        if( this.enabledFindPanel )
        {
            this.findTextField.requestFocusInWindow( ) ;
        }
    }//GEN-LAST:event_jToggleButton1ActionPerformed

    private void jToggleButton2ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jToggleButton2ActionPerformed
        if( this.enabledFindPanel )
        {
            this.enabledFindPanel = !this.enabledFindPanel ;
            this.findPanel.setEnabled( this.enabledFindPanel ) ;
            this.findPanel.setVisible( this.enabledFindPanel ) ;
            this.jToggleButton1.setSelected( this.enabledFindPanel ) ;
        }
        this.enabledReplacePanel = !this.enabledReplacePanel ;
        this.replacePanel.setEnabled( this.enabledReplacePanel ) ;
        this.replacePanel.setVisible( this.enabledReplacePanel ) ;
        if( this.enabledReplacePanel )
        {
            this.replaceWhatField.requestFocusInWindow( ) ;
        }
    }//GEN-LAST:event_jToggleButton2ActionPerformed

    private void jButton14ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jButton14ActionPerformed
        this.save( ) ;
        this.fileIOHandler.tex2DviConverter( ) ;
    }//GEN-LAST:event_jButton14ActionPerformed

    private void jButton15ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jButton15ActionPerformed
        this.save( ) ;
        this.fileIOHandler.tex2pdfConverter( ) ;
        this.filePath = this.fileIOHandler.getFilePath( ) ;
        this.pdfName = this.fileIOHandler.getPdfName( ) ;
        this.previewBool = false ;
        this.togglePdf( ) ;
    }//GEN-LAST:event_jButton15ActionPerformed

    private void jButton16ActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_jButton16ActionPerformed
        this.previewBool = false ;
        this.togglePdf( ) ;
    }//GEN-LAST:event_jButton16ActionPerformed

    private void compilationMenuActionPerformed( java.awt.event.ActionEvent evt )
    {//GEN-FIRST:event_compilationMenuActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_compilationMenuActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox caseSensitiveCheckBox ;

    private javax.swing.JButton closeFindButton ;

    private javax.swing.JButton closeReplaceButton ;

    private javax.swing.JToolBar commandBar ;

    private javax.swing.JMenu compilationMenu ;

    private javax.swing.JMenu editMenu ;

    private javax.swing.JToolBar fileToolBar ;

    private javax.swing.JButton findNextButton ;

    private javax.swing.JPanel findPanel ;

    private javax.swing.JButton findPreviousButton ;

    private javax.swing.JTextField findTextField ;

    private javax.swing.JButton jButton1 ;

    private javax.swing.JButton jButton10 ;

    private javax.swing.JButton jButton11 ;

    private javax.swing.JButton jButton12 ;

    private javax.swing.JButton jButton13 ;

    private javax.swing.JButton jButton14 ;

    private javax.swing.JButton jButton15 ;

    private javax.swing.JButton jButton16 ;

    private javax.swing.JButton jButton2 ;

    private javax.swing.JButton jButton21 ;

    private javax.swing.JButton jButton22 ;

    private javax.swing.JButton jButton23 ;

    private javax.swing.JButton jButton27 ;

    private javax.swing.JButton jButton3 ;

    private javax.swing.JButton jButton33 ;

    private javax.swing.JButton jButton4 ;

    private javax.swing.JButton jButton5 ;

    private javax.swing.JButton jButton6 ;

    private javax.swing.JButton jButton7 ;

    private javax.swing.JButton jButton8 ;

    private javax.swing.JButton jButton9 ;

    private javax.swing.JLabel jLabel1 ;

    private javax.swing.JLabel jLabel2 ;

    private javax.swing.JLabel jLabel3 ;

    private javax.swing.JLabel jLabel4 ;

    private javax.swing.JLabel jLabel5 ;

    private javax.swing.JLabel jLabel6 ;

    private javax.swing.JMenuItem jMenuItem1 ;

    private javax.swing.JMenuItem jMenuItem10 ;

    private javax.swing.JMenuItem jMenuItem11 ;

    private javax.swing.JMenuItem jMenuItem12 ;

    private javax.swing.JMenuItem jMenuItem13 ;

    private javax.swing.JMenuItem jMenuItem14 ;

    private javax.swing.JMenuItem jMenuItem15 ;

    private javax.swing.JMenuItem jMenuItem16 ;

    private javax.swing.JMenuItem jMenuItem2 ;

    private javax.swing.JMenuItem jMenuItem3 ;

    private javax.swing.JMenuItem jMenuItem4 ;

    private javax.swing.JMenuItem jMenuItem5 ;

    private javax.swing.JMenuItem jMenuItem6 ;

    private javax.swing.JMenuItem jMenuItem7 ;

    private javax.swing.JMenuItem jMenuItem8 ;

    private javax.swing.JMenuItem jMenuItem9 ;

    private javax.swing.JPanel jPanel1 ;

    private javax.swing.JScrollPane jScrollPane2 ;

    private javax.swing.JScrollPane jScrollPane3 ;

    private javax.swing.JSeparator jSeparator1 ;

    private javax.swing.JSeparator jSeparator10 ;

    private javax.swing.JSeparator jSeparator11 ;

    private javax.swing.JSeparator jSeparator12 ;

    private javax.swing.JToolBar.Separator jSeparator13 ;

    private javax.swing.JToolBar.Separator jSeparator14 ;

    private javax.swing.JSeparator jSeparator2 ;

    private javax.swing.JSeparator jSeparator3 ;

    private javax.swing.JToolBar.Separator jSeparator4 ;

    private javax.swing.JToolBar.Separator jSeparator5 ;

    private javax.swing.JToolBar.Separator jSeparator6 ;

    private javax.swing.JSeparator jSeparator7 ;

    private javax.swing.JSeparator jSeparator8 ;

    private javax.swing.JSeparator jSeparator9 ;

    private javax.swing.JTabbedPane jTabbedPane1 ;

    private javax.swing.JToggleButton jToggleButton1 ;

    private javax.swing.JToggleButton jToggleButton2 ;

    private javax.swing.JTextArea logTextArea ;

    private javax.swing.JPanel mainPanel ;

    private javax.swing.JMenuBar menuBar ;

    private javax.swing.JPanel previewPanel ;

    private javax.swing.JScrollPane previewScrollPane ;

    private javax.swing.JProgressBar progressBar ;

    private javax.swing.JCheckBox replaceCaseSensitiveCheckBox ;

    private javax.swing.JButton replaceFindButton ;

    private javax.swing.JPanel replacePanel ;

    private javax.swing.JButton replaceReplaceButton ;

    private javax.swing.JTextField replaceWhatField ;

    private javax.swing.JTextField replaceWithField ;

    private javax.swing.JLabel statusAnimationLabel ;

    private javax.swing.JLabel statusMessageLabel ;

    private javax.swing.JPanel statusPanel ;

    private javax.swing.JPanel toolbarPanel ;

    private javax.swing.JMenu toolbarsMenu ;

    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer ;

    private final Timer busyIconTimer ;

    private final Icon idleIcon ;

    private final Icon[ ] busyIcons = new Icon[ 15 ] ;

    private int busyIconIndex = 0 ;

    private boolean previewBool = false ;

    private boolean enabledFindPanel = false ;

    private boolean enabledReplacePanel = false ;

    private Dimension editorSize ;

    private String filePath = null ;

    private String pdfName = null ;

    private String textToPaste = null ;

    protected UndoManager undo = new UndoManager( ) ;

    private JDialog aboutBox ;

    InputStream input ;

    FileIOHandler fileIOHandler ;

    //    Dimension previewDimension = previewScrollPane.getPreferredSize();
    /** used by the find and replace methods
     * the last character position of any already found text in next search*/
    private int nextFindPosn = 0 ;

    /** the last character position of any already found text in previous search*/
    private int prevFindPosn ;

    /** the last text searched for */
    private String findText = null ;

    /** case sensitive find/replace */
    private boolean findCase = false ;

    /** user must confirm text replacement */
    private boolean replaceConfirm = true ;

    //Color highlightColor = new Color(235, 235, 160);
    private Boolean[ ] changed = new Boolean[ 10 ] ;

    protected String TOOLBAR_PATH = "alltoolbars.conf" ;

    /*************************************************
     * MULTIPLE DOCUMENT INTERFACE
     *
     * Tabbed based gui used for handling multiple
     * documents.
     *************************************************/
    private int MAX_TABS = 10 ;

    private int numberOfTabs = 0 ;

    /** * returns the active JTextPane in the MDI
     * @param none */
    public LatexJTextPane[ ] getAllLatextJTextPane( )
    {
        LatexJTextPane[ ] allPanes = new LatexJTextPane[ 10 ] ;
        int l = this.jTabbedPane1.getComponentCount( ) ;

        for( int i = 0; i < l; i++ )
        {
            this.logTextArea.append( i + "\n" ) ;
            JScrollPane jp = ( JScrollPane )this.jTabbedPane1.getComponentAt( i ) ;
            JViewport jv = ( JViewport )jp.getComponent( 0 ) ;
            allPanes[ i ] = ( LatexJTextPane )jv.getView( ) ;
        }

        return allPanes ;
    }

    public JTextPane getActiveJTextPane( )
    {
        JScrollPane jp = ( JScrollPane )this.jTabbedPane1.getSelectedComponent( ) ;
        if( jp == null )
        {
            return null ;
        }
        JViewport jv = ( JViewport )jp.getComponent( 0 ) ;
        JTextPane jt = ( JTextPane )jv.getView( ) ;

        return jt ;
    }

    public LatexJTextPane getLatexJTextPane( )
    {
        return ( LatexJTextPane )this.getActiveJTextPane( ) ;
    }

    private void addTab( String fileName, String filePath, String content )
    {
        if( this.numberOfTabs + 1 > this.MAX_TABS )
        {
            return ;
        }
        this.numberOfTabs++ ;
        if( this.numberOfTabs > 1 )
        {
            this.jButton33.setVisible( true ) ;
        }
        JScrollPane jp = new javax.swing.JScrollPane( ) ;
        jp.setBorder( null ) ;
        jp.setName( "jScrollPane_" + fileName ) ;

        // JTextPane textPane = new JTextPane();
        LatexJTextPane textPane = new LatexJTextPane( ) ;
        textPane.setFilePath( filePath ) ;
        textPane.setFileName( fileName ) ;
        textPane.setPreviouslySaved( true ) ;
        textPane.setBorder( null ) ;
        textPane.setName( "jTextArea_" + fileName ) ;
        textPane.setText( content ) ;
        textPane.getDocument( ).addUndoableEditListener( textPane.undo ) ;
        textPane.getDocument( ).addDocumentListener( new MyDocumentListener( ) ) ;

        jp.setViewportView( textPane ) ;

        this.jTabbedPane1.addTab( fileName, jp ) ;
        this.jTabbedPane1.setSelectedIndex( this.jTabbedPane1.getTabCount( ) - 1 ) ;
    }

    private void addTab( )
    {
        if( this.numberOfTabs + 1 > this.MAX_TABS )
        {
            return ;
        }
        this.numberOfTabs++ ;
        if( this.numberOfTabs > 1 )
        {
            this.jButton33.setVisible( true ) ;
        }

        JScrollPane jp = new javax.swing.JScrollPane( ) ;
        jp.setBorder( null ) ;

        LatexJTextPane textPane = new LatexJTextPane( ) ;
        textPane.setBorder( null ) ;
        textPane.setName( "jTextArea_" + this.numberOfTabs ) ;
        textPane.setBorder( null ) ;
        textPane.getDocument( ).addUndoableEditListener( textPane.undo ) ;
        textPane.getDocument( ).addDocumentListener( new MyDocumentListener( ) ) ;
        jp.setViewportView( textPane ) ;

        this.jTabbedPane1.addTab( "Untitled " + this.numberOfTabs, jp ) ;
        this.jTabbedPane1.setSelectedIndex( this.jTabbedPane1.getTabCount( ) - 1 ) ;

    }

    private void changeTabName( String newTabName )
    {
        this.jTabbedPane1.setTitleAt( this.jTabbedPane1.getSelectedIndex( ), newTabName ) ;
    }

    @Action
    private void removeTab( )
    {
        this.numberOfTabs-- ;
        if( this.numberOfTabs < 2 )
        {
            this.jButton33.setVisible( false ) ;
        }
        System.out.println( this.getLatexJTextPane( ).getFilePath( ) + "\\" + this.getLatexJTextPane( ).getFileName( ) ) ;

        //        stSave.removeFromPathList(getLatexJTextPane().getFilePath() + "\\" + getLatexJTextPane().getFileName());
        if( this.getLatexJTextPane( ).getChanged( ) )
        {
            this.confirmSave( ) ;
        }
        //stSave.stateSave();
        this.jTabbedPane1.remove( this.jTabbedPane1.getSelectedComponent( ) ) ;
    }

    private void doOnExit( )
    {
        LatexJTextPane[ ] jtextpanes = this.getAllLatextJTextPane( ) ;
        int l = this.jTabbedPane1.getComponentCount( ) ;
        this.stSave.clearPathList( ) ;
        for( int i = 0; i < l; i++ )
        {
            this.jTabbedPane1.setSelectedIndex( i ) ;
            if( ( jtextpanes[ i ].getFileName( ) == "" ) || jtextpanes[ i ].getChanged( ) )
            {
                this.confirmSave( ) ;
                this.stSave.addToPathList( jtextpanes[ i ].getFilePath( ) + jtextpanes[ i ].getFileName( ) ) ;
            }
            else
            {
                System.out.println( jtextpanes[ i ].getFilePath( ) + " " + jtextpanes[ i ].getFileName( ) ) ;
                this.stSave.addToPathList( jtextpanes[ i ].getFilePath( ) + jtextpanes[ i ].getFileName( ) ) ;
            }
        }
        this.stSave.stateSave( ) ;
        this.fileIOHandler.deleteTempPdf( ) ;

    }

    class MyWindowListener extends WindowAdapter
    {

        @Override
        public void windowClosing( WindowEvent e )
        {
            LtxPrototypeView.this.doOnExit( ) ;
            System.exit( 0 ) ;
        }
    }

    class MyDocumentListener implements DocumentListener
    {

        @Override
        public void insertUpdate( DocumentEvent e )
        {
            //logTextArea.append("insert\n");
            LtxPrototypeView.this.getLatexJTextPane( ).setChanged( true ) ;
            if( !LtxPrototypeView.this.jTabbedPane1.getTitleAt( LtxPrototypeView.this.jTabbedPane1.getSelectedIndex( ) ).endsWith( "*" ) )
            {
                LtxPrototypeView.this.changeTabName( LtxPrototypeView.this.jTabbedPane1.getTitleAt( LtxPrototypeView.this.jTabbedPane1.getSelectedIndex( ) ) + "*" ) ;
            }
        }

        @Override
        public void removeUpdate( DocumentEvent e )
        {
            //logTextArea.append("remove\n");
        }

        @Override
        public void changedUpdate( DocumentEvent e )
        {
            //logTextArea.append("changed\n");
        }
    }

    /**************************************************
     ******* END OF MULTIPLE DOCUMENT INTERFACE *******
     *************************************************/
    /*************************************************
     * FIND AND REPLACE
     *
     * String operations for finding and replacing
     * text in the documents.
     *************************************************/
    public void findNext( String find )
    {
        //findCase = caseSensitiveCheckBox.isSelected();
        int nextPosn = 0 ;
        if( !find.equals( this.findText ) ) // *** new find word
        {
            this.nextFindPosn = 0 ; // *** start from top
        }
        nextPosn = this.nextIndex( this.getActiveJTextPane( ).getText( ).replaceAll( "\n", "" ), find, this.nextFindPosn, this.findCase ) ;
        //try {
        //logTextArea.append(find+" is found at "+nextPosn+"\n");
        //logTextArea.append(getActiveJTextPane().getText().replaceAll("/n", "")+"/n");
        //logTextArea.append(Utilities.getRowStart(getActiveJTextPane(),nextPosn ) + "/n");

        // } catch (BadLocationException ex) {
        //    Logger.getLogger(LtxPrototypeView.class.getName()).log(Level.SEVERE, null, ex);
        // }

        if( nextPosn >= 0 )
        {

            this.getActiveJTextPane( ).setSelectionStart( nextPosn ) ; // position cursor at word

            this.getActiveJTextPane( ).setSelectionEnd( nextPosn + find.length( ) ) ;

            //getActiveJTextPane().setSelectedTextColor(highlightColor);

            this.nextFindPosn = nextPosn + find.length( ) - 1 ; // reset for next

            this.findText = find ; // save word & case
        }
        else
        {
            this.nextFindPosn = nextPosn ; // set to -1 if not found
            JOptionPane.showMessageDialog( this.getActiveJTextPane( ), find + " not Found!" ) ;
        }
        this.getActiveJTextPane( ).requestFocusInWindow( ) ;
    }

    public void findPrevious( String find )
    {
        //findCase = caseSensitiveCheckBox.isSelected();
        int prevPosn = this.getActiveJTextPane( ).getText( ).length( ) ;
        if( !find.equals( this.findText ) ) // *** new find word
        {
            this.prevFindPosn = this.getActiveJTextPane( ).getText( ).length( ) ; // *** start from bottom
        }
        prevPosn = this.prevIndex( this.getActiveJTextPane( ).getText( ).replaceAll( "\n", "" ), find, this.prevFindPosn, this.findCase ) ;
        this.logTextArea.append( find + "/n" ) ;
        this.logTextArea.append( this.prevFindPosn + "\n" ) ;

        if( prevPosn - find.length( ) >= 0 )
        {

            this.getActiveJTextPane( ).requestFocusInWindow( ) ;

            this.getActiveJTextPane( ).setSelectionStart( prevPosn ) ; // position cursor at word

            this.getActiveJTextPane( ).setSelectionEnd( prevPosn + find.length( ) ) ;
            //getActiveJTextPane().setSelectedTextColor(highlightColor);

            this.prevFindPosn = prevPosn - find.length( ) + 1 ; // reset for previous

            this.findText = find ; // save word & case
        }
        else
        {
            this.prevFindPosn = prevPosn ; // set to -1 if not found
            this.prevFindPosn = this.getActiveJTextPane( ).getText( ).length( ) ; // *** start from bottom
            JOptionPane.showMessageDialog( this.getActiveJTextPane( ), find + " not Found!" ) ;

        }
    }

    /** finds and replaces <B>ALL</B> occurrences of text in a string
     * @param find the text to locate in the string
     * @param replace the text to replace the find text with - if the find
    text exists */
    public void doReplaceWords( String find, String replace )
    {
        int nextPosn = 0 ;
        StringBuffer str = new StringBuffer( ) ;
        this.nextFindPosn = 0 ; // *** begin at start of text
        while( nextPosn >= 0 )
        {
            nextPosn = this.nextIndex( this.getActiveJTextPane( ).getText( ).replaceAll( "\n", "" ), find, this.nextFindPosn, this.findCase ) ;

            if( nextPosn >= 0 )
            { // if text is found
                int rtn = JOptionPane.YES_OPTION ; // default YES for confirm

                this.getActiveJTextPane( ).grabFocus( ) ;
                this.getActiveJTextPane( ).setSelectionStart( nextPosn ) ; // posn cursor at word start
                this.getActiveJTextPane( ).setSelectionEnd( nextPosn + find.length( ) ) ; //select found

                if( this.replaceConfirm )
                { // user replace confirmation
                    rtn = JOptionPane.showConfirmDialog( this.getActiveJTextPane( ), "Found: " + find + "\nReplace with: " + replace, "Text Find & Replace", JOptionPane.YES_NO_CANCEL_OPTION ) ;
                }
                // if don't want confirm or selected yes
                if( !this.replaceConfirm || ( rtn == JOptionPane.YES_OPTION ) )
                {
                    this.getActiveJTextPane( ).replaceSelection( replace ) ;
                    this.nextFindPosn = nextPosn + replace.length( ) ; // set for next search
                    //replaceRange(replace, nextPosn, nextPosn + find.length());
                }
                else if( rtn == javax.swing.JOptionPane.CANCEL_OPTION )
                {
                    this.nextFindPosn = nextPosn + find.length( ) ; // set for next search
                    return ; // cancelled replace - exit method
                }
                else if( !this.replaceConfirm || ( rtn == JOptionPane.NO_OPTION ) )
                {
                    this.nextFindPosn = nextPosn + replace.length( ) ; // set for next search
                    //replaceRange(replace, nextPosn, nextPosn + find.length());
                }
            }
        }
    }

    /** returns next posn of word in text - forward search
     * @return next indexed position of start of found text or -1
     * @param input the string to search
     * @param find the string to find
     * @param start the character position to start the search
     * @param caseSensitive true for case sensitive. false to ignore case
     */
    public int nextIndex( String input, String find, int start, boolean caseSensitive )
    {
        int textPosn = -1 ;
        if( ( input != null ) && ( find != null ) && ( start < input.length( ) ) )
        {
            if( caseSensitive == true )
            { // indexOf() returns -1 if not found
                textPosn = input.indexOf( find, start ) ;
            }
            else
            {
                textPosn = input.toLowerCase( ).indexOf( find.toLowerCase( ), start ) ;
            }
        }
        return textPosn ;
    }

    public int prevIndex( String input, String find, int start, boolean caseSensitive )
    {
        int textPosn = start ;
        if( ( input != null ) && ( find != null ) && ( start > 0 ) )
        {
            if( caseSensitive == true )
            { // indexOf() returns -1 if not found
                textPosn = input.lastIndexOf( find, start ) ;
            }
            else
            {
                textPosn = input.toLowerCase( ).lastIndexOf( find.toLowerCase( ), start ) ;
            }
        }
        return textPosn ;
    }

    /**************************************************
     ************ END OF FIND AND REPLACE ************
     *************************************************/
    /*************************************************
     * XML BUTTONS
     *
     * Operations for creating buttons from xml files
     *************************************************/
    private void readMenuXML( )
    {
        LatexButtonActionListener actionListener = new LatexButtonActionListener( ) ;
        XmlHandler xmlHandler = new XmlHandler( ) ;
        xmlHandler.createToolBars( this.TOOLBAR_PATH, this.commandBar, actionListener, this.toolbarsMenu ) ;
    }

    public class LatexButtonActionListener implements ActionListener
    {

        public void actionPerformed( ActionEvent evt )
        {

            Object ob = evt.getSource( ) ;
            LatexButton lb = ( LatexButton )evt.getSource( ) ;
            LtxPrototypeView.this.addLatexCommand( lb.getPrefix( ), lb.getPostfix( ) ) ;
        }
    }

    /**************************************************
     *************** END OF XML BUTTONS ***************
     *************************************************/
    /*************************************************
     * LOGGING
     *
     * This is used to get the log information from the fileIOHandler.
     * Written this way for expandability. ie: In the future we might want to
     * do seperate things with seperate event types etc.
     *************************************************/
    public void iOeventOccured( String name, String value )
    {
        if( name.equals( "save" ) )
        {
            this.logTextArea.append( value + "\n" ) ;
            if( value.contains( "File saved to" ) )
            {
                this.changeTabName( this.fileIOHandler.getFileName( ) ) ;
                this.getLatexJTextPane( ).setFileName( this.fileIOHandler.getFileName( ) ) ;
                this.getLatexJTextPane( ).setFilePath( this.fileIOHandler.getFilePath( ) ) ;
                this.getLatexJTextPane( ).setPreviouslySaved( true ) ;
                this.getLatexJTextPane( ).setChanged( false ) ;
                if( this.jTabbedPane1.getTitleAt( this.jTabbedPane1.getSelectedIndex( ) ).endsWith( "*" ) )
                {
                    this.changeTabName( this.jTabbedPane1.getTitleAt( this.jTabbedPane1.getSelectedIndex( ) ).substring( 0, this.jTabbedPane1.getTitleAt( this.jTabbedPane1.getSelectedIndex( ) ).length( ) - 2 ) ) ;
                }
            }
        }
        else if( name.equals( "open" ) )
        {
            this.logTextArea.append( value + "\n" ) ;
        }
        else if( name.equals( "tex2dvi" ) )
        {
            this.logTextArea.append( value + "\n" ) ;
        }
        else if( name.equals( "tex2pdf" ) )
        {
            this.logTextArea.append( value + "\n" ) ;
        }
        else if( name.equals( "dvi2ps" ) )
        {
            this.logTextArea.append( value + "\n" ) ;
        }
        else
        {
            this.logTextArea.append( name + ": " + value + "\n" ) ;
        }
    }

    @Action
    public void deneme( )
    {
        this.jTabbedPane1.setSelectedIndex( 2 ) ;
    }
    /**************************************************
     ***************** END OF LOGGING *****************
     *************************************************/
}
